//
//  ViewController.m
//  Book
//
//  Created by mac on 15-12-4.
//  Copyright (c) 2015年 sxh. All rights reserved.
//

#import "ViewController.h"
#import "BookViewController.h"

@interface ViewController ()
{
    NSMutableArray * BookList;
}
@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    self.title  = @"适可而止";
    
//    BookList= @[
//                @"秦时明月",
//                @"天下第一",
//                @"全员加速中",
//                ].mutableCopy;
    UIImage * backgroundImage = [UIImage imageNamed:@"BookShelfCell@2x.png"];
   
   UIColor * backgroundColor = [UIColor colorWithPatternImage:backgroundImage];
    
    self.view.backgroundColor = backgroundColor;

}


//-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
//{
//    return BookList.count;
//}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}


//cell的行高
/*
 @interface NSIndexPath (UITableView)
 
 + (NSIndexPath *)indexPathForRow:(NSInteger)row inSection:(NSInteger)section;
 
 @property(nonatomic,readonly) NSInteger section;
 @property(nonatomic,readonly) NSInteger row;
 
 @end
 */
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 139;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *reuse = @"bookstory";                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuse];
    }
    
    cell.textLabel.text = BookList[indexPath.row];
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    BookViewController * con = [[BookViewController alloc] initWithStyle:UITableViewStyleGrouped];
    
    [self.navigationController pushViewController:con animated:YES];
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
